<template>
  <div>
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="产品名称" prop="pName">
        <el-input
          v-model="queryParams.pName"
          placeholder="请输入产品名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产品类型" prop="pType">
        <el-input
          v-model="queryParams.pType"
          placeholder="请输入产品类型"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="行业" prop="pIndustry">
        <el-select v-model="queryParams.pIndustry" placeholder="请选择行业" clearable>
          <el-option
            v-for="dict in dict.type.product_industry"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="版本型号" prop="pVersion">
        <el-input
          v-model="queryParams.pVersion"
          placeholder="请输入版本型号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产品介绍" prop="pIntroduce">
        <el-input
          v-model="queryParams.pIntroduce"
          placeholder="请输入产品介绍"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="厂商" prop="pManufacturer">
        <el-input
          v-model="queryParams.pManufacturer"
          placeholder="请输入厂商"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="联系人" prop="pContacts">
        <el-input
          v-model="queryParams.pContacts"
          placeholder="请输入联系人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="联系方式" prop="pTel">
        <el-input
          v-model="queryParams.pTel"
          placeholder="请输入联系方式"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="关键词" prop="pKeyword">
        <el-input
          v-model="queryParams.pKeyword"
          placeholder="请输入关键词"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="数据来源" prop="pDataSource">
        <el-input
          v-model="queryParams.pDataSource"
          placeholder="请输入数据来源"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['info:product:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['info:product:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['info:product:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['info:product:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="data" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="ID" align="center" prop="id" />
      <el-table-column label="产品名称" align="center" prop="pName" />
      <el-table-column label="产品类型" align="center" prop="pType" />
      <el-table-column label="行业" align="center" prop="pIndustry">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.product_industry" :value="scope.row.pIndustry"/>
        </template>
      </el-table-column>
      <el-table-column label="版本型号" align="center" prop="pVersion" />
      <el-table-column label="产品介绍" align="center" prop="pIntroduce" />
      <el-table-column label="厂商" align="center" prop="pManufacturer" />
      <el-table-column label="联系人" align="center" prop="pContacts" />
      <el-table-column label="联系方式" align="center" prop="pTel" />
      <el-table-column label="关键词" align="center" prop="pKeyword" />
      <el-table-column label="数据来源" align="center" prop="pDataSource" />
      <el-table-column label="审核状态" align="center" prop="pStatus" >
        <template slot-scope="scope">
          <el-tag v-if="scope.row.pStatus === '0'" type="info">待审核</el-tag>
          <el-tag v-if="scope.row.pStatus === '1'" type="error">不合格</el-tag>
          <el-tag v-if="scope.row.pStatus === '2'" >正常</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleAuditing(scope.row)"
            v-hasPermi="['info:base:auditing']"
          >审核</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleDetail(scope.row)"
            v-hasPermi="['info:caseInfo:detail']"
          >详情</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import ListMixin from "@/minixs/list"
import request from "@/utils/request";
export default {
  name: "list",
  dicts:['product_industry'],
  mixins:[ListMixin],
  data() {
    return {
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        pName: null,
        pType: null,
        pIndustry: null,
        pVersion: null,
        pIntroduce: null,
        pManufacturer: null,
        pContacts: null,
        pTel: null,
        pKeyword: null,
        pDataSource: null,
        pStatus: '0',
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    handleAuditing(row){
      const id = row.id || this.ids[0]
      this.$emit("auditing-handle", {
        id:id,
        open: true,
        title: "审核"+this.title,
        type:'AUDITING'
      })
    },
    /** 查询产品信息列表 */
    getList() {
      this.loading = true;
      request({
        url: '/info/product/list',
        method: 'get',
        params: this.queryParams
      }).then(response => {
        this.data = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },

    /** 导出按钮操作 */
    handleExport() {
      this.download('/info/product/export', {
        ...this.queryParams
      }, `product_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
